<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/27
 * Time: 14:28
 */
namespace app\api\controller\v1;

use app\lib\exception\CategoryException;
use think\Controller;
use app\api\model\Category as CategoryModel;

class Category extends Controller {

    /**
     * 获取商品所有类目列表
     * @return \think\response\Json
     * @throws CategoryException
     */
    public function getCategoryList(){
        $cate = CategoryModel::with(['img'])->select();
        if(!$cate){
            throw new CategoryException();
        }
        return json(['code'=>200,'msg'=>'OK','data'=>$cate]);
    }
}